package com.CST.controller;

import com.CST.common.api.Response;
import com.CST.dto.DateDTO;
import com.CST.service.IAllocationCostService;
import com.CST.service.IBaseCostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/allocationCost")
@Api(tags = "成本分摊")
public class AllocationCostController {
    @Autowired
    private IAllocationCostService allocationCostService;
    
    @Autowired
    private IBaseCostService baseCostService;

    @PostMapping("/quickAmortization")
    @ApiOperation("一键快速分摊")
    public Response quickAmortization(@RequestBody DateDTO dateDTO) throws InterruptedException {
        new Thread(() -> {
            allocationCostService.quickAmortization(dateDTO);
        }).start();
        Thread.sleep(10000);
        return Response.success("分摊成功");
    }

    @PostMapping("/amortization")
    @ApiOperation("定向/强制分摊")
    public Response amortization(@RequestBody DateDTO dateDTO){
        return allocationCostService.amortization(dateDTO);
    }

    @PostMapping("/XZAmortization")
    @ApiOperation("行政分摊")
    public Response XZAmortization(@RequestBody DateDTO dateDTO){
        return allocationCostService.XZAmortization(dateDTO);
    }

    @PostMapping("/YFAmortization")
    @ApiOperation("医辅分摊")
    public Response YFAmortization(@RequestBody DateDTO dateDTO){
        return allocationCostService.YFAmortization(dateDTO);
    }

    @PostMapping("/YJAmortization")
    @ApiOperation("医技分摊")
    public Response YJAmortization(@RequestBody DateDTO dateDTO){
        return allocationCostService.YJAmortization(dateDTO);
    }
    
}
